package cn.com.nes.common.util.listener;

import cn.com.nes.common.util.Globals;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.io.File;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;


public class ApplicationContextListener implements ServletContextListener {

    ScheduledExecutorService pool = Executors.newSingleThreadScheduledExecutor();

    public void contextDestroyed(ServletContextEvent arg0) {
        pool.shutdown();
    }

    public void contextInitialized(ServletContextEvent arg0) {
        Globals.FILEREALPATH = arg0.getServletContext().getRealPath("/").replaceAll("NewGServ", Globals.FILEALIAS);
        Globals.FILEURLPATH = "/" + Globals.FILEALIAS + "/";
        File file = new File(System.getProperty("catalina.home") + File.separator + "agent.dat");
        if (file.exists()) {
            //pool.scheduleAtFixedRate(new AppTimerLogic(null,null), 60, 50, TimeUnit.SECONDS);
            System.out.println("*****************************************解析电话号码归属地*****************************************");
        }
    }

}
